package com.chenfei.api.client;

import com.chenfei.api.constant.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author chenfei
 * @description
 * @since 2018/2/8
 */
@Service
public class UserClient {
    @Autowired
    RestTemplate restTemplate;

    public boolean checkToken(String loginToken){
        boolean result = false;

        String reqJson = "{\"loginToken\":\""+loginToken+"\"}";
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.valueOf("application/json;UTF-8"));
        HttpEntity<String> strEntity = new HttpEntity<String>(reqJson,headers);


        Object res = restTemplate.postForObject(Constants.SERVER_PREFIX_4_CUSTOMER+"/login/checkToken",strEntity,Object.class);
        System.out.println(res.toString());
        return result;
    }
}
